```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Java接口与抽象类深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        .code-block {
            background: #f8f9fa;
            border-left: 4px solid #667eea;
            font-family: 'Courier New', Courier, monospace;
        }
        .feature-card {
            transition: all 0.3s ease;
            border-radius: 8px;
        }
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .divider {
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(0,0,0,0.1), transparent);
        }
        .dropdown-content {
            max-height: 0;
            overflow: hidden;
            transition: max-height 0.3s ease-out;
        }
        .dropdown:hover .dropdown-content {
            max-height: 500px;
        }
        .first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.8;
            margin-right: 8px;
            color: #667eea;
            font-weight: bold;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20 px-4">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col items-center text-center">
                <span class="bg-white bg-opacity-20 rounded-full px-4 py-1 mb-4 text-sm font-medium">Java编程指南</span>
                <h1 class="text-4xl md:text-5xl font-bold mb-6 font-serif">接口与抽象类</h1>
                <p class="text-xl md:text-2xl max-w-3xl opacity-90 mb-8 font-serif">深入理解Java抽象化的两大核心工具</p>
                <div class="flex space-x-4">
                    <a href="#definition" class="px-6 py-3 bg-white text-indigo-700 rounded-full font-medium hover:bg-opacity-90 transition">开始探索</a>
                    <a href="#comparison" class="px-6 py-3 border border-white text-white rounded-full font-medium hover:bg-white hover:bg-opacity-10 transition">对比分析</a>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl py-12 px-4">
        <!-- Definition Section -->
        <section id="definition" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold font-serif">定义与基本特征</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <!-- Interface Card -->
                <div class="feature-card bg-white p-8 shadow-md">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-4">
                            <i class="fas fa-project-diagram text-indigo-600"></i>
                        </div>
                        <h3 class="text-2xl font-bold">接口 (Interface)</h3>
                    </div>
                    <p class="text-gray-600 mb-4">一种特殊的引用类型，类似于类，但只包含常量和方法的声明（不包含具体实现）。</p>
                    
                    <div class="space-y-3">
                        <div class="flex items-start">
                            <div class="text-indigo-500 mt-1 mr-3"><i class="fas fa-check-circle"></i></div>
                            <div>所有方法默认是 <code class="bg-gray-100 px-1 rounded">public</code> 和 <code class="bg-gray-100 px-1 rounded">abstract</code>（Java 8+可包含默认方法和静态方法）</div>
                        </div>
                        <div class="flex items-start">
                            <div class="text-indigo-500 mt-1 mr-3"><i class="fas fa-check-circle"></i></div>
                            <div>只能包含静态常量（<code class="bg-gray-100 px-1 rounded">public static final</code>），不能包含实例变量</div>
                        </div>
                        <div class="flex items-start">
                            <div class="text-indigo-500 mt-1 mr-3"><i class="fas fa-check-circle"></i></div>
                            <div>可以多重继承，一个类可以实现多个接口</div>
                        </div>
                    </div>
                </div>

                <!-- Abstract Class Card -->
                <div class="feature-card bg-white p-8 shadow-md">
                    <div class="flex items-center mb-4">
                        <div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center mr-4">
                            <i class="fas fa-layer-group text-purple-600"></i>
                        </div>
                        <h3 class="text-2xl font-bold">抽象类 (Abstract Class)</h3>
                    </div>
                    <p class="text-gray-600 mb-4">不能被实例化的类，可以包含抽象方法（没有实现）和具体方法（有实现）。</p>
                    
                    <div class="space-y-3">
                        <div class="flex items-start">
                            <div class="text-purple-500 mt-1 mr-3"><i class="fas fa-check-circle"></i></div>
                            <div>可以有构造方法、实例变量和非抽象方法</div>
                        </div>
                        <div class="flex items-start">
                            <div class="text-purple-500 mt-1 mr-3"><i class="fas fa-check-circle"></i></div>
                            <div>只支持单继承，一个类只能继承一个抽象类</div>
                        </div>
                        <div class="flex items-start">
                            <div class="text-purple-500 mt-1 mr-3"><i class="fas fa-check-circle"></i></div>
                            <div>可以包含任何访问修饰符的成员（<code class="bg-gray-100 px-1 rounded">public</code>, <code class="bg-gray-100 px-1 rounded">protected</code>, <code class="bg-gray-100 px-1 rounded">private</code>）</div>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Design Purpose Section -->
        <section id="purpose" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold font-serif">设计目的</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8 mb-12">
                <!-- Interface Purpose -->
                <div class="bg-white p-8 rounded-lg shadow-sm">
                    <h3 class="text-xl font-bold mb-4 text-indigo-600 flex items-center">
                        <i class="fas fa-bullseye mr-2"></i> 接口的用途
                    </h3>
                    <p class="mb-4">用于定义行为的规范，强调类应该做什么，而不关心如何实现。适用于需要不同行为的类（如多态）。</p>
                    <div class="bg-indigo-50 p-4 rounded-lg">
                        <h4 class="font-medium text-indigo-800 mb-2 flex items-center">
                            <i class="fas fa-lightbulb mr-2"></i> 适用场景
                        </h4>
                        <p>当不同类有相似的方法但实现完全不同，或者希望通过多重实现来共享行为时，使用接口更为合适。</p>
                    </div>
                </div>

                <!-- Abstract Class Purpose -->
                <div class="bg-white p-8 rounded-lg shadow-sm">
                    <h3 class="text-xl font-bold mb-4 text-purple-600 flex items-center">
                        <i class="fas fa-project-diagram mr-2"></i> 抽象类的用途
                    </h3>
                    <p class="mb-4">用于在多个相关类之间共享代码，强调类的共同特征和行为。适用于需要提供通用实现的情况。</p>
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-medium text-purple-800 mb-2 flex items-center">
                            <i class="fas fa-lightbulb mr-2"></i> 适用场景
                        </h4>
                        <p>当有一组相关类共享某些实现时，使用抽象类可以减少重复代码，并提供基础的实现。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Inheritance Section -->
        <section id="inheritance" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold font-serif">继承与实现</h2>
            </div>

            <div class="bg-white p-8 rounded-lg shadow-sm mb-8">
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-bold mb-4 text-indigo-600">接口继承</h3>
                        <p>一个类可以实现多个接口，且接口之间可以扩展（即一个接口可以继承另一个接口）。这提供了灵活的多态性和动态绑定。</p>
                    </div>
                    <div>
                        <h3 class="text-xl font-bold mb-4 text-purple-600">抽象类继承</h3>
                        <p>一个类只能继承一个抽象类。抽象类中的抽象方法必须在子类中实现（除非子类也是抽象类），这保证了子类遵循父类的协议。</p>
                    </div>
                </div>
            </div>

            <div class="bg-gray-50 p-6 rounded-lg">
                <div class="mermaid">
                    classDiagram
                        class IService {
                            <<interface>>
                            +add()
                            +update()
                        }
                        
                        class ServiceImpl {
                            <<abstract>>
                            +add()
                            +update()
                        }
                        
                        class UserService {
                            +add()
                        }
                        
                        class TeacherService {
                        }
                        
                        IService <|.. ServiceImpl : implements
                        IService <|.. UserService : implements
                        IService <|.. TeacherService : implements
                        ServiceImpl <|-- UserService : extends
                        ServiceImpl <|-- TeacherService : extends
                </div>
            </div>
        </section>

        <!-- Performance Section -->
        <section id="performance" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold font-serif">性能与效率</h2>
            </div>

            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white p-8 rounded-lg shadow-sm">
                    <h3 class="text-xl font-bold mb-4 text-indigo-600">接口性能</h3>
                    <p>由于接口只定义行为规范，实际运行时的性能通常比抽象类稍低。实现接口需要更高的复杂性，因为JVM在处理接口时需要查找方法实现。</p>
                </div>
                <div class="bg-white p-8 rounded-lg shadow-sm">
                    <h3 class="text-xl font-bold mb-4 text-purple-600">抽象类性能</h3>
                    <p>由于可以包含具体实现，抽象类在某些情况下可能会提高代码执行的效率，特别是在提供共用逻辑的情况下。</p>
                </div>
            </div>
        </section>

        <!-- Key Points Section -->
        <section id="key-points" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold font-serif">核心要点</h2>
            </div>

            <div class="bg-white p-8 rounded-lg shadow-sm">
                <div class="flex mb-6">
                    <div class="first-letter">1</div>
                    <div>
                        <h3 class="text-xl font-bold mb-2">接口：定义标准或规范</h3>
                        <p>接口主要用于定义一组行为规范，强调"做什么"而非"如何做"。它类似于一个契约，规定实现类必须提供哪些功能。</p>
                    </div>
                </div>
                
                <div class="flex">
                    <div class="first-letter">2</div>
                    <div>
                        <h3 class="text-xl font-bold mb-2">抽象类：公共的实现类</h3>
                        <p>抽象类用于封装公共的实现逻辑，子类可以继承这些实现并扩展或覆盖特定行为。它适用于有部分共同实现但又有差异的场景。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Code Example Section -->
        <section id="code-example" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold font-serif">代码示例</h2>
            </div>

            <div class="bg-gray-800 rounded-lg overflow-hidden">
                <div class="flex items-center bg-gray-900 px-4 py-3">
                    <div class="w-3 h-3 rounded-full bg-red-500 mr-2"></div>
                    <div class="w-3 h-3 rounded-full bg-yellow-500 mr-2"></div>
                    <div class="w-3 h-3 rounded-full bg-green-500"></div>
                    <span class="ml-4 text-gray-400 text-sm">InterfaceVsAbstractClass.java</span>
                </div>
                <pre class="p-6 text-gray-100 overflow-x-auto"><code class="language-java">interface IService {
    public void add();
    public void update(); // 接口方法声明
}

abstract class ServiceImpl implements IService{
    @Override
    public void add() {
        // 公共的add方法实现
    }

    @Override
    public void update() {
        // 公共的update方法实现
    }
}

class UserService extends ServiceImpl implements IService{
    @Override
    public void add() { 
        // 这里的add方法不走公共的实现，需要自定义实现
        // 只需重写父类中的add方法即可
    }
}

class TeacherService extends ServiceImpl implements IService{
    // 使用父类的默认实现
}</code></pre>
            </div>
        </section>

        <!-- Comparison Section -->
        <section id="comparison" class="mb-20">
            <div class="flex items-center mb-10">
                <div class="w-12 h-1 bg-indigo-500 mr-4"></div>
                <h2 class="text-3xl font-bold font-serif">对比分析</h2>
            </div>

            <div class="overflow-x-auto">
                <table class="min-w-full bg-white rounded-lg overflow-hidden shadow-sm">
                    <thead class="bg-gray-100">
                        <tr>
                            <th class="py-3 px-6 text-left text-gray-700 font-medium">特性</th>
                            <th class="py-3 px-6 text-left text-indigo-600 font-medium">接口</th>
                            <th class="py-3 px-6 text-left text-purple-600 font-medium">抽象类</th>
                        </tr>
                    </thead>
                    <tbody class="divide-y divide-gray-200">
                        <tr>
                            <td class="py-4 px-6 font-medium">定义</td>
                            <td class="py-4 px-6">行为规范</td>
                            <td class="py-4 px-6">部分实现的类</td>
                        </tr>
                        <tr class="bg-gray-50">
                            <td class="py-4 px-6 font-medium">方法实现</td>
                            <td class="py-4 px-6">Java 8前不能有实现</td>
                            <td class="py-4 px-6">可以有具体方法</td>
                        </tr>
                        <tr>
                            <td class="py-4 px-6 font-medium">变量</td>
                            <td class="py-4 px-6">只能是静态常量</td>
                            <td class="py-4 px-6">可以有实例变量</td>
                        </tr>
                        <tr class="bg-gray-50">
                            <td class="py-4 px-6 font-medium">继承</td>
                            <td class="py-4 px-6">多重继承</td>
                            <td class="py-4 px-6">单继承</td>
                        </tr>
                        <tr>
                            <td class="py-4 px-6 font-medium">构造方法</td>
                            <td class="py-4 px-6">不能有</td>
                            <td class="py-4 px-6">可以有</td>
                        </tr>
                        <tr class="bg-gray-50">
                            <td class="py-4 px-6 font-medium">访问修饰符</td>
                            <td class="py-4 px-6">默认public</td>
                            <td class="py-4 px-6">可以有各种修饰符</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </section>
    </main>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-400 py-12">
        <div class="container mx-auto max-w-5xl px-4">
            <div class="flex flex-col items-center">
                <div class="text-xl font-medium text-white mb-2">技术小馆</div>
                <a href="http://www.yuque.com/jtostring" class="hover:text-white transition hover:underline">www.yuque.com/jtostring</a>
                <div class="flex space-x-4 mt-6">
                    <a href="#" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center hover:bg-indigo-600 hover:text-white transition">
                        <i class="fab fa-github"></i>
                    </a>
                    <a href="#" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center hover:bg-blue-600 hover:text-white transition">
                        <i class="fab fa-twitter"></i>
                    </a>
                    <a href="#" class="w-10 h-10 rounded-full bg-gray-800 flex items-center justify-center hover:bg-red-600 hover:text-white transition">
                        <i class="fab fa-youtube"></i>
                    </a>
                </div>
            </div>
        </div>
    </footer>

    <script>
        // Initialize Mermaid
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            fontFamily: 'Noto Sans SC, sans-serif',
        });
    </script>
</body>
</html>
```